package com.leo.tool.drools;

import org.kie.api.KieServices;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;

public class DroolsTest {

    public static void main(String[] args) {
        KieServices kieServices = KieServices.Factory.get();
        KieContainer kieContainer = kieServices.newKieClasspathContainer();
        KieSession kieSession = kieContainer.newKieSession();

        Order order = new Order();
        order.setOriginalPrice(160d);

        System.out.println("匹配规则前优惠后价格：" + order.getRealPrice());
        kieSession.insert(order);
        kieSession.fireAllRules();
        kieSession.dispose();
        System.out.println("优惠前价格：" + order.getOriginalPrice() + "，优惠后价格：" + order.getRealPrice());
    }
}
